using System;
using System.Collections.Generic;
using System.Text;

using Feathertail;
using Feathertail.Lua;
using libsecondlife;

namespace NestBox
{
    class MoveToCmd : Command
    {
        FeathertailClient _Client;

        #region Command Members

        public void Setup(FeathertailClient Client)
        {
            _Client = Client;
        }

        public string HandleInput(string[] CmdLine)
        {
            if (CmdLine.Length < 3)
            {
                return GetHelpText();
            }

            int x = int.Parse(CmdLine[1]);
            int y = int.Parse(CmdLine[2]);

            MoveTo(x, y);
            return "";
        }

        [AttrLuaFunc("moveto", "Auto-pilot to given region coords","x","y")]
        public void MoveTo(int x, int y)
        {
            _Client.Self.AutoPilotLocal(x, y, _Client.Self.Position.Z);
        }

        public string[] GetCommandStrings()
        {
            return new string[] { "moveto", "walk", "go", "goto" };
        }

        public string GetSummaryText()
        {
            return "Move close to an item or move to specified coordinates.";
        }

        public string GetHelpText()
        {
            return "Usage:  moveto [localid]" + Environment.NewLine + "Usage: moveto [x] [y] [z]";
        }

        #endregion
    }
}
